home *** CD-ROM | disk | FTP | other *** search
- Path: wisipc.weizmann.ac.il!news
- Newsgroups: comp.lang.c++
- Subject: Memory allocation.
- Message-ID: <1996Feb10.161530.26449@wisipc.weizmann.ac.il>
- From: Kajdan Dimitry <cerlpvk>
- Date: Sat, 10 Feb 1996 16:15:30 GMT
- Sender: news@wisipc.weizmann.ac.il (News User)
- Organization: Technion - Israel Institute of Technology
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- Mime-Version: 1.0
- X-Mailer: Mozilla 1.1N (X11; I; OSF1 V3.2 alpha)
- X-Url: news://wisipc.weizmann.ac.il/comp.lang.c++
-
- I'm a starter so the question may seem stupid.
-
- Would someone explain why this program works?
-
- int* func()
- {
-
-
- int b[10];
- for(int i=0;i<9;i++)
- b[i]=i;
- return b;
- }
-
- int main(){
-
- int* x= func();
-
-
- cout<<x[2]<<endl;
- return(1);
- }
-
- The point is that b is allocated on the stack i.e without "new".
-
- Thanks in advance.
-
-